#include "janelaconexao.h"
#include "ui_janelaconexao.h"
#include <QString>

JanelaConexao* JanelaConexao::instance = NULL;

JanelaConexao* JanelaConexao::getInstance(QWidget* parent)
{
    if (instance == NULL)
        instance = new JanelaConexao(parent);
    return instance;
}

JanelaConexao::JanelaConexao(QWidget* parent) : QWidget (parent, Qt::Dialog), ui(new Ui::JanelaConexao)
{
    ui->setupUi(this);
    this->setWindowTitle(QString::fromUtf8("Dados de conexão"));
    connect (this->ui->botao_conectar, SIGNAL(clicked()), this, SLOT (processarNovaConexao()));
    connect(this->ui->botao_cancelar, SIGNAL(clicked()), this, SLOT (close()));
}

void JanelaConexao::processarNovaConexao()
{
    emit this->novoParticipante(this->ui->edit_nome->text(),
                                this->ui->edit_endereco->text(),
                                this->ui->edit_porta->text().toInt());
    this->close();
}
